from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    ParsedQuestionViewSet, 
    ParserTaskViewSet, 
    parse_document_endpoint, 
    document_questions_endpoint,
    import_exercises_endpoint,
    shared_documents_endpoint,
    shared_document_detail_endpoint,
    parse_text_endpoint,
    reparse_document_endpoint,
    convert_format_endpoint
)

router = DefaultRouter()
router.register(r'questions', ParsedQuestionViewSet)
router.register(r'tasks', ParserTaskViewSet)

urlpatterns = [
    path('', include(router.urls)),
    # 文档解析相关端点
    path('documents/<int:document_id>/parse/', parse_document_endpoint, name='document-parse'),
    path('documents/<int:document_id>/reparse/', reparse_document_endpoint, name='document-reparse'),
    path('documents/<int:document_id>/questions/', document_questions_endpoint, name='document-questions'),
    path('documents/shared/', shared_documents_endpoint, name='shared-documents'),
    path('documents/shared/<int:document_id>/', shared_document_detail_endpoint, name='shared-document-detail'),
    # 练习导入端点
    path('exercises/import/', import_exercises_endpoint, name='import-exercises'),
    path('parse-text/', parse_text_endpoint, name='parse-text'),
    # 格式转换器端点
    path('convert-format/', convert_format_endpoint, name='convert-format'),
]

# 注意：共享文档的端点应该在documents应用中定义，不在parser应用中
# 这里临时添加是为了解决前端访问问题，后续应考虑重构到documents应用中 